Skip to content

Conversation

@remi-filament
Copy link
Contributor

This PR fixes #5108 for duplicate journals

When testing this PR I also realized there was a problem assigning chart_template from chart_template_id since company_id was retrieved instead of chart_template_id. I fixed that as well.

I had to copy a few lines from Odoo account/models/chart_template.py code, I added information about that lines in comments, let me know if you think this is not acceptable ?

@MiquelRForgeFlow MiquelRForgeFlow added this to the 17.0 milestone Jul 10, 2025
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may be overcomplicating the code. I think you just need to look for the first journal of each type and assign the XML-ID. Matching per name doesn't worth, as you may rename the journals, install them in another language, or a lot of reasons.

@pedrobaeza
Copy link
Member

And please put the other fix in a separate PR, or at least commit.

@remi-filament
Copy link
Contributor Author

Hi @pedrobaeza thanks for your comments, I moved fix on assign chart_template to #5166.
Regarding the complex code, I believe it is worth it for a few reasons :

  • this is what Odoo core is trying to achieve when updating chart of account (https://github.com/odoo/odoo/blob/7df78a28dd7c05b1ea246e9f0735d8da0cb5486e/addons/account/models/chart_template.py#L257-L284), with an additional fallback to first not yet used journal of correct type
  • for type = "general", you get at least 3 journals (Miscellaneous Operations, Exchange Difference, Cash Basis Taxes) + 1 extra if stock_account is installed (Inventory Valuation) - for this specific case, I believe it is better to try to find the correct one instead of assigning them randomly, falling back to assigning in order if you get no match on code / name.

@pedrobaeza
Copy link
Member

@remi-filament I still think it should be simplified, as all that code Odoo core is if not XML-ID is found, but here we want to just assign one for not triggering that code, so it's enough assigning one journal, not matter which.

@remi-filament remi-filament force-pushed the 17.0-ou-fix-account branch 2 times, most recently from 8284f12 to a918cf1 Compare July 11, 2025 10:34
@remi-filament
Copy link
Contributor Author

Fine @pedrobaeza, I was afraid that maybe somewhere in the code Odoo is trying to get account_journal by XML-id and would fail if we set the incorrect one, but maybe it does not happen.
I simplified the code to assign first of correct type instead !

Let me know if this is OK for you ?

Copy link
Contributor

@MiquelRForgeFlow MiquelRForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope this fix is fine and we don't need to add more conditions (like the code) in the filtered later.

@pedrobaeza pedrobaeza merged commit 6bfcc1a into OCA:17.0 Jul 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[17.0] account try_loading chart template creates duplicate journal

4 participants